
package com.zjff.myshop.common;

/**
 * 订单状态:0待支付/1已支付/2已发货/3交易成功/-1已取消
 */
public enum OrderStatusEnum {
    DEFAULT(-9, "ERROR"),
    ORDER_PRE_PAY(0, "待支付"),
    ORDER_PAID(1, "已支付"),
    ORDER_SHIPPED(2, "已发货"),
    ORDER_EXPRESS(3, "交易成功"),
    ORDER_CANCEL(-1, "已取消");

    private int id;

    private String name;

    OrderStatusEnum(int id, String name) {
        this.id = id;
        this.name = name;
    }

    public static OrderStatusEnum getOrderStatusEnumById(int id) {
        for (OrderStatusEnum orderStatusEnum : OrderStatusEnum.values()) {
            if (orderStatusEnum.getId() == id) {
                return orderStatusEnum;
            }
        }
        return DEFAULT;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
